package com.zyh.thread;

/**
 * @Author zyh
 * @Date 2024/8/7 15:37
 * @Description 线程的睡眠
 */

public class ThreadDemo4 {
    public static void main(String[] args) {

        Thread t1 = new Thread(new MyTask(),"线程A");
        t1.start();

        for (int i = 100; i < 200; i++) {
            System.out.println(Thread.currentThread().getName()+"线程正在打印"+i);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

class MyTask implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread().getName() + "线程正在打印" + i);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
